package com.lingmeng.common.core.exception;

import com.lingmeng.common.core.constant.HttpStatus;
import lombok.Getter;

/**
 * 业务异常(未修改调用)
 *
 * @author ycl
 */
@Getter
public final class ServiceException extends RuntimeException {
	private static final long serialVersionUID = 1L;

	/**
	 * 错误码
	 */
	private Integer code = HttpStatus.ERROR;

	/**
	 * 错误提示
	 */
	private String message;

	/**
	 * 错误明细，内部调试错误
	 * 和 {@link Throwable#getMessage()} 一致的设计
	 */
	private String detailMessage;

	/**
	 * 空构造方法，避免反序列化问题
	 */
	public ServiceException() {
	}

	public ServiceException(String message) {
		this(message, HttpStatus.ERROR);
	}

	public ServiceException(String message, Integer code) {
		this.message = message;
		this.code = code;
	}

	@Override
	public String getMessage() {
		return message;
	}

	public ServiceException setMessage(String message) {
		this.message = message;
		return this;
	}

}